﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using DatabaseCompare.Model;
using DatabaseCompare.Service.Compare;


namespace DatabaseCompare.ServiceImpl.Compare
{
    
    public class FunctionCompare :
        CompareAbleCompare<FunctionInfo>,
        ICompareAbleCompare<FunctionInfo, FunctionCompareResult>
    {


        public FunctionCompareResult Compare(FunctionInfo left, FunctionInfo right)
        {
            // 比较结果.
            FunctionCompareResult result = new FunctionCompareResult();

            // 设置比较参数.
            result.Left = left;
            result.Right = right;

            // 首先简单作非空的判断.
            result.CompareResult = base.CommonCompare(left, right);


            if (result.CompareResult == CommonCompareResult.FullSame)
            {
                // 左右都不为空
                // 需要详细比较.

                // 创建的 SQL 语句.
                if (left.CreateSQL != right.CreateSQL)
                {
                    result.CompareResult = CommonCompareResult.Difference;
                    result.CreateSQLDifference = true;
                }
            }


            // 返回.
            return result;
        }
    }

}
